home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / addmemlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.2 KB  |  93 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addmemlist.c,v 1.4 1996/08/13 13:55:56 digulla Exp $
  4.     $Log: addmemlist.c,v $
  5.     Revision 1.4  1996/08/13 13:55:56  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:02  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang:
  15. */
  16. #include <exec/execbase.h>
  17. #include "machine.h"
  18. #include "memory.h"
  19. #include <aros/libcall.h>
  20.  
  21. /*****************************************************************************
  22.  
  23.     NAME */
  24.     #include <exec/memory.h>
  25.     #include <clib/exec_protos.h>
  26.  
  27. __AROS_LH5(void, AddMemList,
  28.  
  29. /*  SYNOPSIS */
  30.     __AROS_LHA(ULONG,  size,       D0),
  31.     __AROS_LHA(ULONG,  attributes, D1),
  32.     __AROS_LHA(LONG,   pri,        D2),
  33.     __AROS_LHA(APTR,   base,       A0),
  34.     __AROS_LHA(STRPTR, name,       A1),
  35.  
  36. /*  LOCATION */
  37.     struct ExecBase *, SysBase, 103, Exec)
  38.  
  39. /*  FUNCTION
  40.     Add a new block of memory to the system memory lists.
  41.  
  42.     INPUTS
  43.     size       - Size of the block
  44.     attributes - The attributes the memory will have
  45.     pri       - Priority in the list of MemHeaders
  46.     base       - Base address
  47.     name       - A name associated with the memory
  48.  
  49.     RESULT
  50.  
  51.     NOTES
  52.     No argument checking done.
  53.  
  54.     EXAMPLE
  55.  
  56.     BUGS
  57.  
  58.     SEE ALSO
  59.  
  60.     INTERNALS
  61.  
  62.     HISTORY
  63.     8-10-95    created by m. fleischer
  64.        16-10-95    increased portability
  65.  
  66. ******************************************************************************/
  67. {
  68.     __AROS_FUNC_INIT
  69.  
  70.     struct MemHeader *mh;
  71.  
  72.     /* Do I have to look here if it matches some other MemHeader? */
  73.     mh=(struct MemHeader *)base;
  74.     mh->mh_Node.ln_Type=NT_MEMORY;
  75.     mh->mh_Node.ln_Pri=pri;
  76.     mh->mh_Node.ln_Name=name;
  77.     mh->mh_Attributes=attributes;
  78.     mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
  79.     mh->mh_First->mc_Next=NULL;
  80.     mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
  81.     mh->mh_Lower=mh->mh_First;
  82.     mh->mh_Upper=(APTR)((UBYTE *)base+size);
  83.     mh->mh_Free=mh->mh_First->mc_Bytes;
  84.  
  85.     /* Protect the memory list. */
  86.     Forbid();
  87.     /* Add MemHeader */
  88.     Enqueue(&SysBase->MemList,&mh->mh_Node);
  89.     Permit();
  90.     __AROS_FUNC_EXIT
  91. } /* AddMemList */
  92.  
  93.